//
//  LoginModuleAPI.swift
//  FactoryManager-Swift
//
//  Created by 苏州巨细 on 2021/4/6.
//  Copyright © 2021 苏州巨细. All rights reserved.
//

import UIKit
import Moya

enum LoginModuleHttp {
    case homeData([String : Any])
    case imageArr([String : Any])
}

extension LoginModuleHttp : TargetType {
    
    public var validate: Bool {
        return false
    }
    
    //请求URL值
    public var baseURL:URL{
        return URL(string:"http://wl.51zhaobu.com")!
    }
    
    //详细的路径(例如/login)
    public var path: String {
        switch self {
        case .homeData,.imageArr:
            return "/driver/login"
        }
    }
    
    ///请求方式
    public var method:Moya.Method {
        switch self {
        case .homeData,.imageArr:
            return .post
        }
    }
    
    ///请求头信息(子类可复写)
    public var headers: [String : String]? {
        return [
            "OS":"2",
        ]
    }
    
    ///任务,这边可以设置请求参数编码，一般使用JSONEncoding
    public var task: Task {
        switch self {
        case let .homeData(params):
            return .requestParameters(parameters:params, encoding: JSONEncoding.default)
        case let .imageArr(params):
            return .requestParameters(parameters:params, encoding: JSONEncoding.default)
        default:
            return .requestPlain
        }
    
    }
    
    public var sampleData: Data {
        return Data();
    }
    
    
    /// 请在子类中复写定义
    public var showHUD: Bool {
        return true
    }
}
